package com.ruge.system.controller;

import com.ruge.common.util.RestResponse;
import com.ruge.system.pojo.entity.SysLogInfo;
import com.ruge.system.pojo.request.RequestLoginfo;
import com.ruge.system.service.SysLogInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author ruge.wu
 * @program rugeloginInfo
 * @description 系统登录日志
 * @date 2020-03-10 16:34
 **/
@RestController
@RequestMapping("/loginInfo")
@Api(value = "登录日志controller", tags = {"系统登录日志"})
public class SysLogInfoController {
    @Resource
    private SysLogInfoService sysLogInfoService;

    @PostMapping("/list")
    @ApiOperation(value = "获取登录日志详细信息", notes = "根据url的id来获取详细信息")
    public RestResponse list(@RequestBody(required = false) RequestLoginfo loginfo) {
        return RestResponse.success().setData(sysLogInfoService.findAll(loginfo));
    }
    @DeleteMapping("{id}")
    @ApiOperation(value = "删除菜单", notes = "根据url的id来指定删除对象")
    public RestResponse delete(@PathVariable Long id) {
        sysLogInfoService.deleteById(id);
        return RestResponse.success();
    }

    @ApiOperation(value = "批量操作", notes = "根据url的id来指定批量操作对象")
    @PostMapping("/batch")
    public RestResponse batch(@RequestBody Map<String, List<SysLogInfo>> map) {
        return RestResponse.success().setData(sysLogInfoService.batch(map));
    }
}
